package com.jch.dm6_active_object.example.sample;

import com.jch.dm6_active_object.ActiveObjectProxy;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class SampleClientOfReusableActiveObject {

    private static final Logger log = LogManager.getLogger(SampleClientOfReusableActiveObject.class);

    public static void main(String[] args) throws InterruptedException, ExecutionException {
        SampleActiveObject sao = ActiveObjectProxy.newInstance(SampleActiveObject.class,new SampleActiveObjectImpl(), Executors.newCachedThreadPool());
        Future<String> f = null;
        log.info("Before calling active object");
        try{
            f = sao.process("Something",1);
        } catch (Exception e){
            e.printStackTrace();
        }
        Thread.sleep(40);
        log.info(f.get());
    }
}
